package com.snow.datasource.route;

import org.springframework.jdbc.datasource.AbstractDataSource;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;

/**
 * @Description
 * @Author fanxl 315620726@qq.com
 * @Date 2020/12/17
 **/
public abstract class AbstractRoutingDataSource  extends AbstractDataSource {

    /**
     * 数据库选择
     *
     * @return
     */
    protected abstract DataSource determineDataSource();

    @Override
    public Connection getConnection() throws SQLException {
        return determineDataSource().getConnection();
    }

    @Override
    public Connection getConnection(String username, String password) throws SQLException {
        return determineDataSource().getConnection(username,password);
    }
}
